<?
	require_once('init.php');
	require_once('dataModel.php');

	if($_SESSION["UID"]=="" || $_SESSION['flag']!='6275ffcfb9cd8f95984b93b0a7bfcefd')
	{
		$h_tourl="login.php";
		header("Location:".$h_tourl);
		exit;
	}

	if(!$_GET['SortNo'])
	{
		$SortNo = 1;
	}
	else
	{
		$SortNo = $_GET['SortNo'];
	}


    /*获得所有会员数量*/
	$sql = "select COUNT(*) as RowNum from sort". $SortNo ."";
	
	$db = MySQL::getInstance('','r-w'); 
	$result = $db->fetch($db->query($sql));
    $rs_count=$result["RowNum"];
    
    /*获得当前的页码数*/
	if(!$_GET['pgno'])
	{
		$PageNo = 1;
	}
	else
	{
		$PageNo = $_GET['pgno'];
	}

	$total_showpages = 10;  /*需显示的总页*/
	$num_perpage = 10;    /*每页所显示的数量*/

	$from = ($PageNo-1)*$num_perpage;	/*每页所显示的起始数量*/
	$total_pages = ceil($rs_count / $num_perpage); /*总页数*/
	
	if($total_pages>=$PageNo+$total_showpages)
	{
		$start = $PageNo;
		$stop = $PageNo+$total_showpages-1;
	}
	elseif($total_pages < $PageNo+$total_showpages)
	{
		if($total_pages>$total_showpages)
		{
			$start = $total_pages-$total_showpages+1;
			$stop = $total_pages;		
		}
		else
		{
			$start = 1;
			$stop = $total_pages;
		}
	}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=<?='utf-8';?>" />
	<title><?=$AllPageTitle;?></title>
	<link href="css/CenterMenu.css" rel="stylesheet" type="text/css" />
	<link href="css/Buttonstyle.css" rel="stylesheet" type="text/css" />
	
	
	<? include("alljs.php"); ?>
	
	<script language="javascript">
   		function ChangeSort(SortNo)
   		{
			self.location='sortmanager.php?SortNo='+SortNo;
		}    

   		function DeleteSort(UID,SortNo)
   		{
			var strSQL = "";                      
			strSQL+= "UID="+UID;
			strSQL+= "&SortNo="+SortNo;
			strSQL+= "&Type=DeleteSort";

//			alert (strSQL);

			parent.hiConfirm('确定删除当前类别吗?', '系统提示', function(r) 
			{       
				if (r) 
				{
					$.post("varifyData.php",strSQL,function(msg)
					{
					   	if (msg=='1')
					   	{	
							parent.hiAlert("数据删除完毕!", '系统提示');
							setTimeout('location.reload();parent.$("#popup_ok").click();',3000); //主动关闭提示，否则遮住了
							return false;
					   	}
					})
				}	
			})	
		}    
	</script>
</head>

<body>
	<div id="MenuRighttitle" ><div style="padding-left:245px;padding-top:5px;"><b><?="类别".$SortNo."基本资料";?></b></div></div>
	
	<div class="inner-container">
		<div class="empinfo_a01" style="width:650px;margin-left:70px;border:0px solid blue;">	
			<div class="empinfo_a02" style="width:600px;">
				<div class="goodsaddnew_a02" style="width:100px;margin-top:3px;">
					<select name="sortno" id="sortno" onchange="ChangeSort(this.value);">
						<option <?=$SortNo=="2"?"selected":"";?> value="1"><?="类别一";?></option>
						<option <?=$SortNo=="2"?"selected":"";?> value="2"><?="类别二";?></option>
						<option <?=$SortNo=="3"?"selected":"";?> value="3"><?="类别三";?></option>
						<option <?=$SortNo=="4"?"selected":"";?> value="4"><?="类别四";?></option>
						<option <?=$SortNo=="5"?"selected":"";?> value="5"><?="类别五";?></option>
					</select>
				</div>
				
				<div class="empinfo_b01" style="margin-left:40px;"><b><?="总数量:".$result["RowNum"];?><b></div>
				<button class=btnblue_mouseout onmouseover="this.className='btnblue_mouseover'" onmouseout="this.className='btnblue_mouseout'" onmousedown="this.className='btnblue_mousedown'"  onmouseup="this.className='btnblue_mouseup'" style="height:25px;width:50px;float:right;margin-right:20px;" onclick="self.location='sortaddnew.php?Type=0&SortNo=<?=$SortNo;?>'" ><?="新  增";?></button>
            </div> 

			<div class="empinfo_a03" style="width:640px;">
				<!--显示列表头-->
				<div class="colormanager_a04">
					<div class="colormanager_a06" style="color:#629EB0"><b>序号</b></div>
					<div class="colormanager_a07" style="color:#629EB0"><b><?="类别".$SortNo."名称";?></b></div>
					<div class="colormanager_a08" style="color:#629EB0"><b><?="类别".$SortNo."名称(英文)";?></b></div>
					<div class="colormanager_a09" style="color:#629EB0"><b>备注</b></div>
					<div class="colormanager_a10" style="color:#629EB0"><b>操作</b></div>
		    	</div>

				<!--显示具体内容-->
				<?
				$strSQL= "select id,sort".$SortNo."name as sortname,sort".$SortNo."name_e as sortname_e,remark ";  
				$strSQL.="from sort".$SortNo." ";  
				$strSQL.="order by id limit ".$from.",".$num_perpage."";

				$db = MySQL::getInstance('','r-w'); 
				$DBR=$db->query($strSQL); 

				$bkcolor="#F5F5F5";
		    	$i_web = 1;
		      	while($rsGoods=$db->fetch($DBR))
		    	{
		      	    if ($bkcolor=="white")
		      	    {$bkcolor="#F5F5F5";}
		      	    else
		      	    {$bkcolor="white";}
		      	    
		      	?>
					<div class="colormanager_a04" style="background-color:<?=$bkcolor;?>">
						<? $ShowNum=$num_perpage*($PageNo-1)+$i_web; ?>
						<div class="colormanager_a06"><?=$ShowNum;?></div>
						<div class="colormanager_a07"><?=$rsGoods["sortname"];?></div>
						<div class="colormanager_a08"><?=$rsGoods["sortname_e"];?></div>
						<div class="colormanager_a09"><?=$rsGoods["remark"];?></div>
						<div class="colormanager_a10" style="line-height:0px;" >
							<button class="btnblue_mouseout" style="width:50px;height:25px;margin-left:3px;margin-top:1px;" onmouseover="this.className='btnblue_mouseover'" onmouseout="this.className='btnblue_mouseout'" onmousedown="this.className='btnblue_mousedown'"  onmouseup="this.className='btnblue_mouseup'" onclick="self.location='sortaddnew.php?ID=<?=$rsGoods["id"];?>&Type=1&pgno=<?=$PageNo;?>&SortNo=<?=$SortNo;?>'" ><?="编辑";?></button>
				            <button class="btnblue_mouseout" style="width:50px;height:25px;margin-left:3px;margin-top:1px;" onmouseover="this.className='btnblue_mouseover'" onmouseout="this.className='btnblue_mouseout'" onmousedown="this.className='btnblue_mousedown'"  onmouseup="this.className='btnblue_mouseup'" onclick="DeleteSort('<?=$rsGoods["id"];?>','<?=$SortNo;?>')"><?="删除";?></button>
						</div>
			    	</div>
		      	<?
					$i_web++;
				}
				?>
				
				<!-- 显示 页码-->
				<div class="empinfo_a04" style="width:640px;" background-color:white; " align="center">
					<?
					if($PageNo>1)
					{ 
						$npage = $PageNo-1;  /*上一页*/
					?>
						<span><a class="paging_page" href="sortmanager.php?pgno=1"><b>首页</b></a></span> 
						<span><a class="paging_page" href="sortmanager.php?pgno=<?=$npage;?>"><b>上一页</b></a></span>
					<?
					}
					else
					{
					?>
						<span class="paging_page"><b>首页</b></span>
						<span class="paging_page"><b>上一页</b></span>
					<?
					}
					for($i=$start;$i<=$stop;$i++)
					{
						if($i==$PageNo)
						{
					?>
						<span class="paging_page"><b><?=$i?></b></span>
					<?
					 	}
						else
						{
					?>	
						<span class="paging_page"><a href="sortmanager.php?pgno=<?=$i;?>"><b><?=$i;?></b></a></span>
					<?	
						}  
					}
					
				   	if($PageNo < $total_pages)
				   	{
				   		$npage = $PageNo+1;   /*下页*/
				  	?>   
				  		<span class="paging_page"><a href="sortmanager.php?pgno=<?=$npage;?>"><b>下一页</b></a></span> 
				  		<span class="paging_page"><a href="sortmanager.php?pgno=<?=$total_pages;?>"><b>尾页</b></a></span>
				  	<? 
				  	}
				  	else
				  	{?>
						<span class="paging_page"><b>下一页</b></span>
						<span class="paging_page"><b>尾页</b></span>
				  	<?
				  	}
				  	?>
		    	</div>
			</div>
		</div>
	</div>
</body>

</html>
